import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { scene } from "../../utils/init";
import { MyLight } from "../effect/MylLight";
import { Sky } from "../effect/Sky";
import { Car } from "./Car";

export function loadManager(path, successFn) {
  const gltfLoader = new GLTFLoader();
  gltfLoader.load(
    path,
    (gltf) => successFn(gltf.scene),
    (process) => {
      console.log("加载进度", process);
    },
    (error) => {
      throw new Error(error);
    }
  );
}

loadManager("glb/car.glb", (model) => {
  console.log(model); // 模型对象信息
  new Car(model, scene, canera, controls)
  new MyLight(scene) // 实例化灯光
  new Sky(scene) // 实例化背景
});
